package com.cskaoyan.gateway.controller.shopping;

/**
 * @author pengyehua
 * @date 2020/12/20 19:49
 */

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductNavigationService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.PanelContentDto;
import com.mall.shopping.dto.PanelContentResponse;
import com.mall.user.annotation.Anonymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品导航栏显示
 */
@RestController
public class ProductNavigationController {

    @Reference(check = false)
    IProductNavigationService productNavigationService;

    @GetMapping("shopping/navigation")
    @Anonymous
    public ResponseData navigation(){
        PanelContentResponse panelContentResponse = productNavigationService.queryPanelContent();
        if(!panelContentResponse.getCode().equals(ShoppingRetCode.SUCCESS.getCode())){
            return new ResponseUtil<>().setErrorMsg(panelContentResponse.getMsg());
        }
        return new ResponseUtil<List<PanelContentDto>>().setData(panelContentResponse.getPanelContentDtoList(),
                panelContentResponse.getMsg());
    }
}
